package com.gec.controller;

import com.gec.dao.BookDao;
import com.gec.dao.BookDao1;
import com.gec.dao.BookDao2;
import com.gec.entity.Book;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 调用去数据库中查询客房信息BookDao的方法
 */
@WebServlet("/BookListServlet2")
public class BookListServlet2 extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        BookDao2 bookDao = new BookDao2();

        //去bookDao中调用查询客房的方法
        List<Book> books = bookDao.getBooks();
        //接下来就需要将查询出来的数据转发到jsp页面 index.jsp
        //将数据存放到request作用域中然后转发到页面去
        request.setAttribute("booklist",books);
        request.getRequestDispatcher("index2.jsp").forward(request,response);
    }
}